package flexconsole.controls {
	
	import flash.display.Sprite;
	
	import mx.controls.DataGrid;
	
	/**
	 * TODO
	 *
	 * <p>The AdvDataGrid tag inherits all of the tag attributes of its superclass,  and adds the following tag attributes:</p>
	 *
	 * <pre>
	 * &lt;controls:AdvDataGrid
	 *    <strong>Properties</strong>
	 *    rowColorFunction="<i>No default</i>"
	 *    /&gt;
	 * </pre>
	 *
	 * @see mx.controls.DataGrid
	 */
	public class AdvDataGrid extends DataGrid {
		
		/**
		 * TODO
		 *
		 * Method signature is: <br />
		 * <code>rowColorFunction(item:Object, rowIndex:int, dataIndex:int, color:uint):uint</code>
		 * This function is return <code>color</code>
		 */
		public var rowColorFunction:Function;
		
		public function AdvDataGrid() {
			super();
		}
		
		/**
		 * 	@inheritDoc
		 */
		override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void {
			if (rowColorFunction is Function && dataProvider != null) {
				var item:Object;
				if (dataIndex < dataProvider.length) {
					item = dataProvider[dataIndex];
				}
				
				if (item) {
					color = rowColorFunction(item, rowIndex, dataIndex, color);
				}
			}
			super.drawRowBackground(s, rowIndex, y, height, color, dataIndex);
		}
	
	}
}